package com.hospital.insurancedip.module.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hospital.insurancedip.module.controller.vo.BatchUpDip;
import com.hospital.insurancedip.module.entity.InsuranceLogs;
import com.hospital.insurancedip.module.mapper.InsuranceLogsMapper;
import com.hospital.insurancedip.module.service.InsuranceLogsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lvyao
 * @since 2021-09-26
 */
@Service
public class InsuranceLogsServiceImpl extends ServiceImpl<InsuranceLogsMapper, InsuranceLogs> implements InsuranceLogsService {

    @Resource
    private  InsuranceLogsMapper insuranceLogsMapper;

    @Override
    public boolean insertInfo(String serNo,String updateDate, String pid,String vid,String jsonIn, String flag,byte[] jsonout) {
        return insuranceLogsMapper.insertSpecial(serNo,updateDate,pid,vid,jsonIn,flag, jsonout);
    }

    @Override
    public String getDipUrl() {
        return insuranceLogsMapper.getDipUrl();
    }

    @Override
    public String getSettleFrundFlag(String setl_id, String mdtrt_id,String topic) {
        if (topic.toLowerCase().equals("md-his-orcl-stream")){
            return insuranceLogsMapper.getSettleFrundFlag5(setl_id, mdtrt_id);
        }else if (topic.toLowerCase().equals("rj-his-orcl-stream")){
            return insuranceLogsMapper.getSettleFrundFlag3(setl_id, mdtrt_id);
        }else if (topic.toLowerCase().equals("gxgk-his-orcl-stream")){
            return insuranceLogsMapper.getSettleFrundFlag6(setl_id, mdtrt_id);
        }else if (topic.toLowerCase().equals("hj-his-orcl-stream")){
            return insuranceLogsMapper.getSettleFrundFlag8(setl_id, mdtrt_id);
        }else if (topic.toLowerCase().equals("dfl-his-orcl-stream")){
            return insuranceLogsMapper.getSettleFrundFlag2(setl_id, mdtrt_id);
        }else if (topic.toLowerCase().equals("jel-his-orcl-stream")){
            return insuranceLogsMapper.getSettleFrundFlag(setl_id, mdtrt_id);
        }else if (topic.toLowerCase().equals("cjp-his-orcl-stream")){
            return insuranceLogsMapper.getSettleFrundFlag4(setl_id, mdtrt_id);
        }else if (topic.toLowerCase().equals("bt-his-orcl-stream")){
            return insuranceLogsMapper.getSettleFrundFlag7(setl_id, mdtrt_id);
        }else {
            return insuranceLogsMapper.getSettleFrundFlag1(setl_id, mdtrt_id);
        }
    }

    @Override
    public List<InsuranceLogs> selecBysql(String serialNo, String date, String topic) {
        if (topic.toLowerCase().equals("md-his-orcl-stream")){
            return insuranceLogsMapper.selecBysql5(serialNo,date);
        }else if (topic.toLowerCase().equals("rj-his-orcl-stream")){
            return insuranceLogsMapper.selecBysql3(serialNo,date);
        }else if (topic.toLowerCase().equals("gxgk-his-orcl-stream")){
            return insuranceLogsMapper.selecBysql6(serialNo,date);
        }else if (topic.toLowerCase().equals("hj-his-orcl-stream")){
            return insuranceLogsMapper.selecBysql8(serialNo,date);
        }else if (topic.toLowerCase().equals("dfl-his-orcl-stream")){
            return insuranceLogsMapper.selecBysql2(serialNo,date);
        }else if (topic.toLowerCase().equals("jel-his-orcl-stream")){
            return insuranceLogsMapper.selecBysql(serialNo,date);
        }else if (topic.toLowerCase().equals("cjp-his-orcl-stream")){
            return insuranceLogsMapper.selecBysql4(serialNo,date);
        }else if (topic.toLowerCase().equals("bt-his-orcl-stream")){
            return insuranceLogsMapper.selecBysql7(serialNo,date);
        }else {
            return insuranceLogsMapper.selecBysql1(serialNo,date);
        }
    }

    @Override
    public List<InsuranceLogs> selecByPidVisitId(String patientId, String visitId, String topic) {
        if (topic.toLowerCase().equals("md-his-orcl-stream")){
            return insuranceLogsMapper.selecByPidVisitId5(patientId,visitId);
        }else if (topic.toLowerCase().equals("rj-his-orcl-stream")){
            return insuranceLogsMapper.selecByPidVisitId3(patientId,visitId);
        }else if (topic.toLowerCase().equals("gxgk-his-orcl-stream")){
            return insuranceLogsMapper.selecByPidVisitId6(patientId,visitId);
        }else if (topic.toLowerCase().equals("hj-his-orcl-stream")){
            return insuranceLogsMapper.selecByPidVisitId8(patientId,visitId);
        }else if (topic.toLowerCase().equals("dfl-his-orcl-stream")){
            return insuranceLogsMapper.selecByPidVisitId2(patientId,visitId);
        }else if (topic.toLowerCase().equals("jel-his-orcl-stream")){
            return insuranceLogsMapper.selecByPidVisitId(patientId,visitId);
        }else if (topic.toLowerCase().equals("cjp-his-orcl-stream")){
            return insuranceLogsMapper.selecByPidVisitId4(patientId,visitId);
        }else if (topic.toLowerCase().equals("bt-his-orcl-stream")){
            return insuranceLogsMapper.selecByPidVisitId7(patientId,visitId);
        }else {
            return insuranceLogsMapper.selecByPidVisitId1(patientId,visitId);
        }
    }

    @Override
    public List<BatchUpDip> getBatchUpDip(String beginDate, String endDate, String topic) {

        if (topic.toLowerCase().equals("md-his-orcl-stream")){
            return insuranceLogsMapper.getBatchUpDip5(beginDate,endDate);
        }else if (topic.toLowerCase().equals("rj-his-orcl-stream")){
            return insuranceLogsMapper.getBatchUpDip3(beginDate,endDate);
        }else if (topic.toLowerCase().equals("gxgk-his-orcl-stream")){
            return insuranceLogsMapper.getBatchUpDip6(beginDate,endDate);
        }else if (topic.toLowerCase().equals("hj-his-orcl-stream")){
            return insuranceLogsMapper.getBatchUpDip8(beginDate,endDate);
        }else if (topic.toLowerCase().equals("dfl-his-orcl-stream")){
            return insuranceLogsMapper.getBatchUpDip2(beginDate,endDate);
        }else if (topic.toLowerCase().equals("jel-his-orcl-stream")){
            return insuranceLogsMapper.getBatchUpDip(beginDate,endDate);
        }else if (topic.toLowerCase().equals("cjp-his-orcl-stream")){
            return insuranceLogsMapper.getBatchUpDip4(beginDate,endDate);
        }else if (topic.toLowerCase().equals("bt-his-orcl-stream")){
            return insuranceLogsMapper.getBatchUpDip7(beginDate,endDate);
        }else {
            return insuranceLogsMapper.getBatchUpDip1(beginDate,endDate);
        }
    }

    @Override
    public List<BatchUpDip> getUnUpDip(String beginDate, String endDate, String topic) {
        if (topic.toLowerCase().equals("md-his-orcl-stream")){
            return insuranceLogsMapper.getUnUpDip5(beginDate,endDate);
        }else if (topic.toLowerCase().equals("rj-his-orcl-stream")){
            return insuranceLogsMapper.getUnUpDip3(beginDate,endDate);
        }else if (topic.toLowerCase().equals("gxgk-his-orcl-stream")){
            return insuranceLogsMapper.getUnUpDip6(beginDate,endDate);
        }else if (topic.toLowerCase().equals("hj-his-orcl-stream")){
            return insuranceLogsMapper.getUnUpDip8(beginDate,endDate);
        }else if (topic.toLowerCase().equals("dfl-his-orcl-stream")){
            return insuranceLogsMapper.getUnUpDip2(beginDate,endDate);
        }else if (topic.toLowerCase().equals("jel-his-orcl-stream")){
            return insuranceLogsMapper.getUnUpDip(beginDate,endDate);
        }else if (topic.toLowerCase().equals("cjp-his-orcl-stream")){
            return insuranceLogsMapper.getUnUpDip4(beginDate,endDate);
        }else if (topic.toLowerCase().equals("bt-his-orcl-stream")){
            return insuranceLogsMapper.getUnUpDip7(beginDate,endDate);
        }else {
            return insuranceLogsMapper.getUnUpDip1(beginDate,endDate);
        }
    }

    @Override
    public List<BatchUpDip> getSettleDataAllDip(String beginDate, String endDate, String topic) {
        if (topic.toLowerCase().equals("md-his-orcl-stream")){
            return insuranceLogsMapper.getSettleDataAllDip5(beginDate,endDate);
        }else if (topic.toLowerCase().equals("rj-his-orcl-stream")){
            return insuranceLogsMapper.getSettleDataAllDip3(beginDate,endDate);
        }else if (topic.toLowerCase().equals("gxgk-his-orcl-stream")){
            return insuranceLogsMapper.getSettleDataAllDip6(beginDate,endDate);
        }else if (topic.toLowerCase().equals("hj-his-orcl-stream")){
            return insuranceLogsMapper.getSettleDataAllDip8(beginDate,endDate);
        }else if (topic.toLowerCase().equals("dfl-his-orcl-stream")){
            return insuranceLogsMapper.getSettleDataAllDip2(beginDate,endDate);
        }else if (topic.toLowerCase().equals("jel-his-orcl-stream")){
            return insuranceLogsMapper.getSettleDataAllDip(beginDate,endDate);
        }else if (topic.toLowerCase().equals("cjp-his-orcl-stream")){
            return insuranceLogsMapper.getSettleDataAllDip4(beginDate,endDate);
        }else if (topic.toLowerCase().equals("bt-his-orcl-stream")){
            return insuranceLogsMapper.getSettleDataAllDip7(beginDate,endDate);
        }else {
            return insuranceLogsMapper.getSettleDataAllDip1(beginDate,endDate);
        }
    }

    @Override
    public List<InsuranceLogs> selectbyPid(String patientId, String visitId, String topic) {
        if (topic.toLowerCase().equals("md-his-orcl-stream")){
            return insuranceLogsMapper.selectbyPid5(patientId,visitId);
        }else if (topic.toLowerCase().equals("rj-his-orcl-stream")){
            return insuranceLogsMapper.selectbyPid3(patientId,visitId);
        }else if (topic.toLowerCase().equals("gxgk-his-orcl-stream")){
            return insuranceLogsMapper.selectbyPid6(patientId,visitId);
        }else if (topic.toLowerCase().equals("hj-his-orcl-stream")){
            return insuranceLogsMapper.selectbyPid8(patientId,visitId);
        }else if (topic.toLowerCase().equals("dfl-his-orcl-stream")){
            return insuranceLogsMapper.selectbyPid2(patientId,visitId);
        }else if (topic.toLowerCase().equals("jel-his-orcl-stream")){
            return insuranceLogsMapper.selectbyPid(patientId,visitId);
        }else if (topic.toLowerCase().equals("cjp-his-orcl-stream")){
            return insuranceLogsMapper.selectbyPid4(patientId,visitId);
        }else if (topic.toLowerCase().equals("bt-his-orcl-stream")){
            return insuranceLogsMapper.selectbyPid7(patientId,visitId);
        }else {
            return insuranceLogsMapper.selectbyPid1(patientId,visitId);
        }
    }


}
